package com.example.demo.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.demo.entity.UserAndRole;
import com.example.demo.mapper.UserAndRoleMapper;
import com.example.demo.service.UserAndRoleService;

@Service
@Transactional
public class UserAndRoleServiceImpl implements UserAndRoleService{

	@Autowired
	private UserAndRoleMapper userAndRoleMapper;
	
	private List<UserAndRole> userAndRolelist;
	
	private UserAndRole userAndRole1;
	
	@Override
	public int addUserAndRole(UserAndRole userAndRole) {
		// TODO Auto-generated method stub
		return userAndRoleMapper.insertUserAndRole(userAndRole);
	}

	@Override
	public int delUserAndRole(UserAndRole userAndRole) {
		// TODO Auto-generated method stub
		return userAndRoleMapper.deleteUserAndRole(userAndRole);
	}

	@Override
	public int updateRoleAndPermission(UserAndRole userAndRole) {
		// TODO Auto-generated method stub
		return userAndRoleMapper.updateUserAndRole(userAndRole);
	}

	@Override
	public List<UserAndRole> selectUserAndRole() {
		// TODO Auto-generated method stub
		userAndRolelist=new ArrayList<UserAndRole>();
		userAndRolelist=userAndRoleMapper.selectUserAndRole();
		return userAndRolelist;
	}

	@Override
	public UserAndRole selectOneUserAndRole(UserAndRole userAndRole) {
		// TODO Auto-generated method stub
		userAndRole1= new UserAndRole();
		userAndRole1= userAndRoleMapper.selectOneUserAndRole(userAndRole); 
		return userAndRole1;
	}

}
